using B.S.Passport.Infacetrue;
using Microsoft.EntityFrameworkCore;
using System.Reflection;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//����ע��
builder.Services.AddSwaggerGen(x =>
{
    var file = Path.Combine(AppContext.BaseDirectory, "B.S.Passport.Read.API.xml");
    x.IncludeXmlComments(file, true);
});
//注册上下文
builder.Services.AddDbContext<DbcontextWMS>(c => c.UseSqlServer(builder.Configuration.GetConnectionString("Db")));

builder.Services.AddMediatR(x => x.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
// 注册仓储
builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseReository<>));
// 注册 DBHelper
builder.Services.AddScoped<DAL.DBHelper1>();
var app = builder.Build();
app.UseCors(p => p.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
